package com.ficus.road.maintain.core.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * 告警对象
 *
 * @Author hao.zhou1
 * @Since 2021/4/7 下午6:49
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class HistoryHit implements Serializable {
    //长度，单位m
    Float length;
    //面积，单位m^2
    Float area;
    //角度
    Float angle;
    //高差
    Integer heightDiff;
    //倒伏数量
    Integer fallDownNumber;
    //道路类型 ROAD_TYPE_UNKNOWN-未知; ROAD_TYPE_ASPHALT-柏油路 ROAD_TYPE_CEMENT-沥青路
    String roadType;
    //人头数
    Integer headCount;
    //舒适指数
    Float comfortRate;
    private String type;
    private Long hitTime;
    private List<HitSubject> subjects;
    private HistoryHitAttrs attrs;
    private SeverityType severityType;
    //宽度
    private Integer width;

    public static HistoryHit fromHit(Hit hit) {
        return HistoryHit.builder()
                .type(hit.getType())
                .area(hit.getArea())
                .attrs(HistoryHitAttrs.fromHitAttrs(hit.getAttrs()))
                .hitTime(hit.getHitTime())
                .subjects(hit.getSubjects())
                .width(hit.getWidth())
                .length(hit.getLength())
                .angle(hit.getAngle())
                .heightDiff(hit.getHeightDiff())
                .fallDownNumber(hit.getFallDownNumber())
                .roadType(hit.getRoadType())
                .comfortRate(hit.getComfortRate())
                .build();
    }
}
